using SimpleFramework;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

namespace Game
{
    public class HotupWindow : UIWindow
    {
        //[UIProperty(Type = typeof(Scrollbar), Path = "ProgressBar")]
        //protected Scrollbar m_ProgressBar;
        //[UIProperty(Type = typeof(Text), Path = "ProgressBar/Text")]
        //protected Text m_ProgressText;
        //[UIProperty(Type = typeof(Text), Path = "Text")]
        //protected Text m_VersionText;

        //protected UnityEvent<string> m_Complete = new UnityEvent<string>();

        //public HotupWindow(string assetPath)
        //    : base(assetPath)
        //{

        //}

        //protected override void Start()
        //{
        //    HotupSystem.Instance.Reset();
        //    HotupSystem.Instance.StateChanged.AddListener(OnStateChanged);
        //    HotupSystem.Instance.ProgressHandler.AddListener(OnLoadProgress);
        //    HotupSystem.Instance.Complete.AddListener(OnComplete);
        //    HotupSystem.Instance.Change(HotupStateId.Check);
        //    TimerSystem.Instance.Add(this);
        //}

        //protected override void OnDisable()
        //{
        //    HotupSystem.Instance.Clear();
        //}

        //private void OnStateChanged(HotupStateId id)
        //{
        //    if (id == HotupStateId.LoadAsset)
        //    {
        //        m_VersionText.GetComponent<Text>().text = Global.Version;
        //    }
        //}

        //private void OnLoadProgress(ulong curBytes, ulong allBytes)
        //{
        //    m_ProgressText.text = HotupUtils.ToMKB(curBytes) + "/" + HotupUtils.ToMKB(allBytes);
        //    m_ProgressBar.size = (float)curBytes / allBytes;
        //}

        //private void OnComplete(string error)
        //{
        //    m_Complete.Invoke(error);
        //    Close();
        //}

        //public bool Update()
        //{
        //    HotupSystem.Instance.Update();
        //    return m_GameObject == null;
        //}

        //public void Complete(UnityAction<string> callback)
        //{
        //    m_Complete.RemoveAllListeners();
        //    m_Complete.AddListener(callback);
        //}
    }
}